package com.quectel.core.module.device.entity.mongo;

import com.quectel.constant.BackupConfigConstants;
import com.quectel.core.constants.MongoCollectionConstants;
import com.quectel.core.module.device.entity.DeviceCurrentAlarmEntity;
import com.quectel.core.module.device.entity.DeviceEntity;
import com.quectel.util.client.mongo.MongoBaseModel;
import lombok.Data;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.util.Date;
import java.util.Map;

@Data
@CompoundIndex(name = "idx_device_id", def = "{'deviceEntity._id': 1}", background = true)
@CompoundIndex(name = "idx_tenant_village", def = "{'deviceEntity.tenantId': 1,'deviceEntity.villageId': 1}", background = true)
@Document(MongoCollectionConstants.DEVICE_ALARM_LOG)
public class MongoDeviceAlarmLogModel implements MongoBaseModel {

    @MongoId
    private Long id;

    private String originalData;

    private Map<String, Object> parsedData;

    /**
     * 告警开始时间
     */
    @Indexed(name = "idx_start_time", background = true, expireAfterSeconds = BackupConfigConstants.MONGO_LOG_DATA_DEFAULT_RETAIN_SECONDS)
    private Date startTime;

    /**
     * 告警结束时间
     */
    private Date finishTime;

    /**
     * 恢复状态1已回复0未恢复
     */
    private Byte recoveryState;
    /**
     * 处理方式1自动恢复2手动恢复
     */
    private Byte handMethod;


    private DeviceEntity deviceEntity;

    private DeviceCurrentAlarmEntity deviceCurrentAlarmEntity;
}
